﻿using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using LINQtoFxCop.Core;

namespace LINQtoFxCop.Metrics.Assemblies
{
  public class AssemblyNbTypes : MetricsIntrospectionRule
  {
    protected AssemblyNbTypes(string name, string resourceName, Assembly assembly)
      : base(name, resourceName, assembly)
    { }
    public AssemblyNbTypes()
      : base("AssemblyNbTypes")
    { }

    protected override IEnumerable<QueryResult> Query()
    {
      return
        from @assembly in Assemblies
        where @assembly.NbTypes() > MetricThreshold()
        select Result(@assembly, @assembly.NbTypes());
    }
  }
}
